<html>
  <body>
    <script>
      function run() {
        var startDate = {year: 2009, month: 6, date : 1,
          hour : 0, minute: 0, second: 0};
        var endDate = {year: 2009, month: 7, date : 15,
          hour : 0, minute: 0, second: 0};

        var calendars = ['en.usa#holiday@group.v.calendar.google.com',
            'en.canadian#holiday@group.v.calendar.google.com'];

        google.calendar.read.getEvents(eventCallback, calendars, startDate, endDate);
      }

      function eventCallback(response) {
        var out = '';
        for (var i = 0; i < response.length; ++i) {
          if ('error' in response[i]) {
            out += 'Can\'t load calendar for ' + response[i].email + '\n';
            continue;
          }

          out += 'CALENDAR: ' + response[i].email + '\n';
          if ('name' in response[i]) {
            out += 'NAME: ' + response[i].name + '\n';
          }

          var events = response[i]['events'];
          for(var j = 0; j < events.length; ++j) {
            var e = events[j];
            if ('title' in e) {
              out += 'Title = ' + e.title + '\n';
            }
            if ('location' in e) {
              out += 'Location = ' + e.location + '\n';
            }
            out += '---------\n';
          }
        }
        alert(out);
      }

    </script>

    <button onclick="run()">Get US and<br>Canadian holidays</button>

  </body>
</html>

